<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <link rel="stylesheet" href="../../plugin/bootstrap/css/bootstrap.min.css">
  <link rel="stylesheet" href="../../plugin/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="../../system/css/login.css"/>

  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
	<div class="navbar-header">
		<a class="logo-a"></a>
	</div>
</nav>
<div class="login-content">
    <div class="login-bg"></div>
    <div class="login-box">
        <form id="loginForm" class="login-form">
            <div class="login-title">用户登录</div>
            <div class="form-group has-feedback">
                <input type="text" name="username"  class="form-control" placeholder="Email"  max="14" min="3" require="必填项" >
                <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input  name="password"  type="password" class="form-control" placeholder="Password"  require="必填项" nochinese="密码不能包括中文" >
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <div class="code-content">
                    <input type="text"  name="verification"  class="form-control code-input" placeholder="验证码" require="必填项" data-position="position-a">
                    <span class="fa fa-key code-icon form-control-feedback"></span>
                </div>
                <!-- <img id="verificationCode" src="/verificationCode" class="pointer code-img"> -->
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <button id="loginBtn" type="button" class="btn btn-info btn-block btn-flat">登录</button>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="copyright-light copyright-section">
    <p>Copyright © 2020. All rights reserved.</p>
</div>
<script src="../../plugin/jquery/jquery.min.js"></script>
<script src="../../plugin/bootstrap/js/bootstrap.min.js"></script>
<script>
    $(function () {
    	// if (window.top !== window.self) { window.top.location = window.location };
        $(".code-img").on('click', function () {
            $(this).attr('src', '/verificationCode?_' + new Date().getTime());
        });
        $("#loginBtn").on('click', function () {
            if (!doValidForm(loginForm)) {
                return;
            }
            $.ajax({
                type: "POST",
                url: "/login",
                data: $(".login-form").serialize(),
                dataType: "json",
                success: function (data) {
                    if (data.status == 200) {
                        layer.msg(data.msg, {
                            offset: '30%',
                            time: 800
                        }, function () {
                            window.location.href = "/index?_" + new Date().getTime();
                        });
                    } else {
                        layer.msg(data.msg, { offset: '30%', time: 2000 });
                        $("#verificationCode").click();
                    }
                }
            });
        });
        $(document).keyup(function (event) {
            if (event.keyCode == 13) {
                $("#loginBtn").click();
            }
        });
    });
</script>
</body>
</html>